home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Bank smakow / BankSmakow.air / BankSmakow.swf / scripts / mx / controls / FlexNativeMenu.as < prev    next >
Text File  |  2009-12-16  |  26KB  |  847 lines

  1. package mx.controls
  2. {
  3.    import flash.display.InteractiveObject;
  4.    import flash.display.NativeMenu;
  5.    import flash.display.NativeMenuItem;
  6.    import flash.display.Stage;
  7.    import flash.events.Event;
  8.    import flash.events.EventDispatcher;
  9.    import flash.events.TimerEvent;
  10.    import flash.ui.Keyboard;
  11.    import flash.utils.Timer;
  12.    import flash.xml.XMLNode;
  13.    import mx.collections.ArrayCollection;
  14.    import mx.collections.ICollectionView;
  15.    import mx.collections.XMLListCollection;
  16.    import mx.collections.errors.ItemPendingError;
  17.    import mx.controls.menuClasses.IMenuDataDescriptor;
  18.    import mx.controls.treeClasses.DefaultDataDescriptor;
  19.    import mx.core.Application;
  20.    import mx.core.EventPriority;
  21.    import mx.core.UIComponentGlobals;
  22.    import mx.core.mx_internal;
  23.    import mx.events.CollectionEvent;
  24.    import mx.events.CollectionEventKind;
  25.    import mx.events.FlexNativeMenuEvent;
  26.    import mx.managers.ILayoutManagerClient;
  27.    import mx.managers.ISystemManager;
  28.    
  29.    use namespace mx_internal;
  30.    
  31.    public class FlexNativeMenu extends EventDispatcher implements ILayoutManagerClient, IFlexContextMenu
  32.    {
  33.       
  34.       mx_internal static const VERSION:String = "3.5.0.12683";
  35.       
  36.       private static var MNEMONIC_INDEX_CHARACTER:String = "_";
  37.        
  38.       
  39.       private var _labelField:String = "label";
  40.       
  41.       private var _initialized:Boolean = false;
  42.       
  43.       private var _keyEquivalentFunction:Function;
  44.       
  45.       private var keyEquivalentFieldChanged:Boolean = false;
  46.       
  47.       private var _mnemonicIndexFunction:Function;
  48.       
  49.       private var showRootChanged:Boolean = false;
  50.       
  51.       private var _mnemonicIndexField:String = "mnemonicIndex";
  52.       
  53.       private var invalidatePropertiesFlag:Boolean = false;
  54.       
  55.       private var _hasRoot:Boolean = false;
  56.       
  57.       private var labelFieldChanged:Boolean = false;
  58.       
  59.       private var _keyEquivalentModifiersFunction:Function;
  60.       
  61.       private var dataProviderChanged:Boolean = false;
  62.       
  63.       private var _nestLevel:int = 1;
  64.       
  65.       private var _processedDescriptors:Boolean = false;
  66.       
  67.       private var _updateCompletePendingFlag:Boolean = false;
  68.       
  69.       private var mnemonicIndexFieldChanged:Boolean = false;
  70.       
  71.       private var _nativeMenu:NativeMenu;
  72.       
  73.       private var dataDescriptorChanged:Boolean = false;
  74.       
  75.       private var _dataDescriptor:IMenuDataDescriptor;
  76.       
  77.       private var _showRoot:Boolean = true;
  78.       
  79.       mx_internal var _rootModel:ICollectionView;
  80.       
  81.       private var _labelFunction:Function;
  82.       
  83.       private var keyEquivalentModifiersFunctionChanged:Boolean = false;
  84.       
  85.       private var _keyEquivalentField:String = "keyEquivalent";
  86.       
  87.       public function FlexNativeMenu()
  88.       {
  89.          _nativeMenu = new NativeMenu();
  90.          _dataDescriptor = new DefaultDataDescriptor();
  91.          _keyEquivalentModifiersFunction = keyEquivalentModifiersDefaultFunction;
  92.          super();
  93.          _nativeMenu.addEventListener(Event.DISPLAYING,menuDisplayHandler,false,0,true);
  94.       }
  95.       
  96.       public function get nestLevel() : int
  97.       {
  98.          return _nestLevel;
  99.       }
  100.       
  101.       [Bindable("nativeMenuUpdate")]
  102.       public function get nativeMenu() : NativeMenu
  103.       {
  104.          return _nativeMenu;
  105.       }
  106.       
  107.       public function set nestLevel(param1:int) : void
  108.       {
  109.          _nestLevel = param1;
  110.          invalidateProperties();
  111.       }
  112.       
  113.       public function get updateCompletePendingFlag() : Boolean
  114.       {
  115.          return _updateCompletePendingFlag;
  116.       }
  117.       
  118.       [Bindable("mnemonicIndexFunctionChanged")]
  119.       public function get mnemonicIndexFunction() : Function
  120.       {
  121.          return _mnemonicIndexFunction;
  122.       }
  123.       
  124.       [Bindable("keyEquivalentFunctionChanged")]
  125.       public function get keyEquivalentFunction() : Function
  126.       {
  127.          return _keyEquivalentFunction;
  128.       }
  129.       
  130.       protected function parseLabelToMnemonicIndex(param1:String) : int
  131.       {
  132.          var _loc7_:String = null;
  133.          var _loc8_:int = 0;
  134.          var _loc2_:RegExp = new RegExp(MNEMONIC_INDEX_CHARACTER + MNEMONIC_INDEX_CHARACTER,"g");
  135.          var _loc3_:Array = param1.split(_loc2_);
  136.          var _loc4_:int = _loc3_.length;
  137.          var _loc5_:int = 0;
  138.          var _loc6_:int = 0;
  139.          while(_loc6_ < _loc4_)
  140.          {
  141.             if((_loc8_ = (_loc7_ = String(_loc3_[_loc6_])).indexOf(MNEMONIC_INDEX_CHARACTER)) >= 0)
  142.             {
  143.                return _loc8_ + _loc5_;
  144.             }
  145.             _loc5_ += _loc7_.length + MNEMONIC_INDEX_CHARACTER.length;
  146.             _loc6_++;
  147.          }
  148.          return -1;
  149.       }
  150.       
  151.       public function validateSize(param1:Boolean = false) : void
  152.       {
  153.       }
  154.       
  155.       public function set updateCompletePendingFlag(param1:Boolean) : void
  156.       {
  157.          _updateCompletePendingFlag = param1;
  158.       }
  159.       
  160.       private function clearMenu(param1:NativeMenu) : void
  161.       {
  162.          var _loc2_:int = param1.numItems;
  163.          var _loc3_:int = 0;
  164.          while(_loc3_ < _loc2_)
  165.          {
  166.             param1.removeItemAt(0);
  167.             _loc3_++;
  168.          }
  169.       }
  170.       
  171.       public function set mnemonicIndexFunction(param1:Function) : void
  172.       {
  173.          if(_mnemonicIndexFunction != param1)
  174.          {
  175.             _mnemonicIndexFunction = param1;
  176.             mnemonicIndexFieldChanged = true;
  177.             invalidateProperties();
  178.             dispatchEvent(new Event("mnemonicIndexFunctionChanged"));
  179.          }
  180.       }
  181.       
  182.       [Bindable("keyEquivalentChanged")]
  183.       public function get keyEquivalentField() : String
  184.       {
  185.          return _keyEquivalentField;
  186.       }
  187.       
  188.       public function set mnemonicIndexField(param1:String) : void
  189.       {
  190.          if(_mnemonicIndexField != param1)
  191.          {
  192.             _mnemonicIndexField = param1;
  193.             mnemonicIndexFieldChanged = true;
  194.             invalidateProperties();
  195.             dispatchEvent(new Event("mnemonicIndexFieldChanged"));
  196.          }
  197.       }
  198.       
  199.       private function itemSelectHandler(param1:Event) : void
  200.       {
  201.          var _loc5_:* = false;
  202.          var _loc2_:NativeMenuItem = param1.target as NativeMenuItem;
  203.          var _loc3_:String = dataDescriptor.getType(_loc2_.data).toLowerCase();
  204.          if(_loc3_ == "check")
  205.          {
  206.             _loc5_ = !dataDescriptor.isToggled(_loc2_.data);
  207.             _loc2_.checked = _loc5_;
  208.             dataDescriptor.setToggled(_loc2_.data,_loc5_);
  209.          }
  210.          var _loc4_:FlexNativeMenuEvent;
  211.          (_loc4_ = new FlexNativeMenuEvent(FlexNativeMenuEvent.ITEM_CLICK)).nativeMenu = _loc2_.menu;
  212.          _loc4_.index = _loc2_.menu.getItemIndex(_loc2_);
  213.          _loc4_.nativeMenuItem = _loc2_;
  214.          _loc4_.label = _loc2_.label;
  215.          _loc4_.item = _loc2_.data;
  216.          dispatchEvent(_loc4_);
  217.       }
  218.       
  219.       [Bindable("keyEquivalentModifiersFunctionChanged")]
  220.       public function get keyEquivalentModifiersFunction() : Function
  221.       {
  222.          return _keyEquivalentModifiersFunction;
  223.       }
  224.       
  225.       public function set keyEquivalentFunction(param1:Function) : void
  226.       {
  227.          if(_keyEquivalentFunction != param1)
  228.          {
  229.             _keyEquivalentFunction = param1;
  230.             keyEquivalentFieldChanged = true;
  231.             invalidateProperties();
  232.             dispatchEvent(new Event("keyEquivalentFunctionChanged"));
  233.          }
  234.       }
  235.       
  236.       private function keyEquivalentModifiersDefaultFunction(param1:Object) : Array
  237.       {
  238.          var i:int = 0;
  239.          var modifier:* = undefined;
  240.          var data:Object = param1;
  241.          var modifiers:Array = [];
  242.          var xmlModifiers:Array = ["@altKey","@cmdKey","@ctrlKey","@shiftKey","@commandKey","@controlKey"];
  243.          var objectModifiers:Array = ["altKey","cmdKey","ctrlKey","shiftKey","commandKey","controlKey"];
  244.          var keyboardModifiers:Array = [Keyboard.ALTERNATE,Keyboard.COMMAND,Keyboard.CONTROL,Keyboard.SHIFT,Keyboard.COMMAND,Keyboard.CONTROL];
  245.          if(data is XML)
  246.          {
  247.             i = 0;
  248.             for(; i < xmlModifiers.length; i++)
  249.             {
  250.                try
  251.                {
  252.                   modifier = data[xmlModifiers[i]];
  253.                   if(modifier[0] == true)
  254.                   {
  255.                      modifiers.push(keyboardModifiers[i]);
  256.                   }
  257.                }
  258.                catch(e:Error)
  259.                {
  260.                   continue;
  261.                }
  262.             }
  263.          }
  264.          else if(data is Object)
  265.          {
  266.             i = 0;
  267.             for(; i < objectModifiers.length; i++)
  268.             {
  269.                try
  270.                {
  271.                   modifier = data[objectModifiers[i]];
  272.                   if(String(modifier).toLowerCase() == "true")
  273.                   {
  274.                      modifiers.push(keyboardModifiers[i]);
  275.                   }
  276.                }
  277.                catch(e:Error)
  278.                {
  279.                   continue;
  280.                }
  281.             }
  282.          }
  283.          return modifiers;
  284.       }
  285.       
  286.       private function menuDisplayHandler(param1:Event) : void
  287.       {
  288.          var _loc2_:NativeMenu = param1.target as NativeMenu;
  289.          var _loc3_:FlexNativeMenuEvent = new FlexNativeMenuEvent(FlexNativeMenuEvent.MENU_SHOW);
  290.          _loc3_.nativeMenu = _loc2_;
  291.          dispatchEvent(_loc3_);
  292.       }
  293.       
  294.       private function populateMenu(param1:NativeMenu, param2:ICollectionView) : NativeMenu
  295.       {
  296.          var menu:NativeMenu = param1;
  297.          var collection:ICollectionView = param2;
  298.          var collectionLength:int = collection.length;
  299.          var i:int = 0;
  300.          while(i < collectionLength)
  301.          {
  302.             try
  303.             {
  304.                insertMenuItem(menu,i,collection[i]);
  305.             }
  306.             catch(e:ItemPendingError)
  307.             {
  308.             }
  309.             i++;
  310.          }
  311.          return menu;
  312.       }
  313.       
  314.       public function set processedDescriptors(param1:Boolean) : void
  315.       {
  316.          _processedDescriptors = param1;
  317.       }
  318.       
  319.       [Bindable("labelFieldChanged")]
  320.       public function get labelField() : String
  321.       {
  322.          return _labelField;
  323.       }
  324.       
  325.       public function set dataDescriptor(param1:IMenuDataDescriptor) : void
  326.       {
  327.          _dataDescriptor = param1;
  328.          dataDescriptorChanged = true;
  329.       }
  330.       
  331.       private function createMenu() : NativeMenu
  332.       {
  333.          var _loc1_:NativeMenu = new NativeMenu();
  334.          _loc1_.addEventListener(Event.DISPLAYING,menuDisplayHandler,false,0,true);
  335.          return _loc1_;
  336.       }
  337.       
  338.       private function collectionChangeHandler(param1:CollectionEvent) : void
  339.       {
  340.          if(param1.kind == CollectionEventKind.ADD)
  341.          {
  342.             dataProviderChanged = true;
  343.             invalidateProperties();
  344.          }
  345.          else if(param1.kind == CollectionEventKind.REMOVE)
  346.          {
  347.             dataProviderChanged = true;
  348.             invalidateProperties();
  349.          }
  350.          else if(param1.kind == CollectionEventKind.REFRESH)
  351.          {
  352.             dataProviderChanged = true;
  353.             dataProvider = dataProvider;
  354.             invalidateProperties();
  355.          }
  356.          else if(param1.kind == CollectionEventKind.RESET)
  357.          {
  358.             dataProviderChanged = true;
  359.             invalidateProperties();
  360.          }
  361.          else if(param1.kind == CollectionEventKind.UPDATE)
  362.          {
  363.             dataProviderChanged = true;
  364.             invalidateProperties();
  365.          }
  366.       }
  367.       
  368.       public function set dataProvider(param1:Object) : void
  369.       {
  370.          var _loc3_:XMLList = null;
  371.          var _loc4_:Array = null;
  372.          if(mx_internal::_rootModel)
  373.          {
  374.             mx_internal::_rootModel.removeEventListener(CollectionEvent.COLLECTION_CHANGE,collectionChangeHandler);
  375.          }
  376.          if(typeof param1 == "string")
  377.          {
  378.             param1 = new XML(param1);
  379.          }
  380.          else if(param1 is XMLNode)
  381.          {
  382.             param1 = new XML(XMLNode(param1).toString());
  383.          }
  384.          else if(param1 is XMLList)
  385.          {
  386.             param1 = new XMLListCollection(param1 as XMLList);
  387.          }
  388.          if(param1 is XML)
  389.          {
  390.             _hasRoot = true;
  391.             _loc3_ = new XMLList();
  392.             _loc3_ += param1;
  393.             mx_internal::_rootModel = new XMLListCollection(_loc3_);
  394.          }
  395.          else if(param1 is ICollectionView)
  396.          {
  397.             mx_internal::_rootModel = ICollectionView(param1);
  398.             if(mx_internal::_rootModel.length == 1)
  399.             {
  400.                _hasRoot = true;
  401.             }
  402.          }
  403.          else if(param1 is Array)
  404.          {
  405.             mx_internal::_rootModel = new ArrayCollection(param1 as Array);
  406.          }
  407.          else if(param1 is Object)
  408.          {
  409.             _hasRoot = true;
  410.             (_loc4_ = []).push(param1);
  411.             mx_internal::_rootModel = new ArrayCollection(_loc4_);
  412.          }
  413.          else
  414.          {
  415.             mx_internal::_rootModel = new ArrayCollection();
  416.          }
  417.          mx_internal::_rootModel.addEventListener(CollectionEvent.COLLECTION_CHANGE,collectionChangeHandler,false,0,true);
  418.          dataProviderChanged = true;
  419.          invalidateProperties();
  420.          var _loc2_:CollectionEvent = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
  421.          _loc2_.kind = CollectionEventKind.RESET;
  422.          collectionChangeHandler(_loc2_);
  423.          dispatchEvent(_loc2_);
  424.       }
  425.       
  426.       public function get showRoot() : Boolean
  427.       {
  428.          return _showRoot;
  429.       }
  430.       
  431.       public function validateDisplayList() : void
  432.       {
  433.       }
  434.       
  435.       protected function parseLabelToString(param1:String) : String
  436.       {
  437.          var _loc7_:String = null;
  438.          var _loc2_:RegExp = new RegExp(MNEMONIC_INDEX_CHARACTER,"g");
  439.          var _loc3_:RegExp = new RegExp(MNEMONIC_INDEX_CHARACTER + MNEMONIC_INDEX_CHARACTER,"g");
  440.          var _loc4_:Array;
  441.          var _loc5_:int = (_loc4_ = param1.split(_loc3_)).length;
  442.          var _loc6_:int = 0;
  443.          while(_loc6_ < _loc5_)
  444.          {
  445.             _loc7_ = String(_loc4_[_loc6_]);
  446.             _loc4_[_loc6_] = _loc7_.replace(_loc2_,"");
  447.             _loc6_++;
  448.          }
  449.          return _loc4_.join(MNEMONIC_INDEX_CHARACTER);
  450.       }
  451.       
  452.       public function set keyEquivalentModifiersFunction(param1:Function) : void
  453.       {
  454.          if(_keyEquivalentModifiersFunction != param1)
  455.          {
  456.             _keyEquivalentModifiersFunction = param1;
  457.             keyEquivalentModifiersFunctionChanged = true;
  458.             invalidateProperties();
  459.             dispatchEvent(new Event("keyEquivalentModifiersFunctionChanged"));
  460.          }
  461.       }
  462.       
  463.       public function get hasRoot() : Boolean
  464.       {
  465.          return _hasRoot;
  466.       }
  467.       
  468.       public function set keyEquivalentField(param1:String) : void
  469.       {
  470.          if(_keyEquivalentField != param1)
  471.          {
  472.             _keyEquivalentField = param1;
  473.             keyEquivalentFieldChanged = true;
  474.             invalidateProperties();
  475.             dispatchEvent(new Event("keyEquivalentFieldChanged"));
  476.          }
  477.       }
  478.       
  479.       protected function itemToLabel(param1:Object) : String
  480.       {
  481.          var data:Object = param1;
  482.          if(data == null)
  483.          {
  484.             return " ";
  485.          }
  486.          if(labelFunction != null)
  487.          {
  488.             return labelFunction(data);
  489.          }
  490.          if(data is XML)
  491.          {
  492.             try
  493.             {
  494.                if(data[labelField].length() != 0)
  495.                {
  496.                   data = data[labelField];
  497.                }
  498.             }
  499.             catch(e:Error)
  500.             {
  501.             }
  502.          }
  503.          else if(data is Object)
  504.          {
  505.             try
  506.             {
  507.                if(data[labelField] != null)
  508.                {
  509.                   data = data[labelField];
  510.                }
  511.             }
  512.             catch(e:Error)
  513.             {
  514.             }
  515.          }
  516.          else if(data is String)
  517.          {
  518.             return String(data);
  519.          }
  520.          try
  521.          {
  522.             return data.toString();
  523.          }
  524.          catch(e:Error)
  525.          {
  526.             return " ";
  527.          }
  528.       }
  529.       
  530.       public function set initialized(param1:Boolean) : void
  531.       {
  532.          _initialized = param1;
  533.       }
  534.       
  535.       [Bindable("mnemonicIndexChanged")]
  536.       public function get mnemonicIndexField() : String
  537.       {
  538.          return _mnemonicIndexField;
  539.       }
  540.       
  541.       public function get processedDescriptors() : Boolean
  542.       {
  543.          return _processedDescriptors;
  544.       }
  545.       
  546.       public function get dataDescriptor() : IMenuDataDescriptor
  547.       {
  548.          return IMenuDataDescriptor(_dataDescriptor);
  549.       }
  550.       
  551.       [Bindable("collectionChange")]
  552.       public function get dataProvider() : Object
  553.       {
  554.          if(mx_internal::_rootModel)
  555.          {
  556.             return mx_internal::_rootModel;
  557.          }
  558.          return null;
  559.       }
  560.       
  561.       public function display(param1:Stage, param2:int, param3:int) : void
  562.       {
  563.          nativeMenu.display(param1,param2,param3);
  564.       }
  565.       
  566.       protected function commitProperties() : void
  567.       {
  568.          var _loc1_:ICollectionView = null;
  569.          var _loc2_:* = undefined;
  570.          if(showRootChanged)
  571.          {
  572.             if(!_hasRoot)
  573.             {
  574.                showRootChanged = false;
  575.             }
  576.          }
  577.          if(dataProviderChanged || showRootChanged || labelFieldChanged || dataDescriptorChanged)
  578.          {
  579.             dataProviderChanged = false;
  580.             showRootChanged = false;
  581.             labelFieldChanged = false;
  582.             dataDescriptorChanged = false;
  583.             if(mx_internal::_rootModel && !_showRoot && _hasRoot)
  584.             {
  585.                _loc2_ = mx_internal::_rootModel.createCursor().current;
  586.                if(_loc2_ != null && _dataDescriptor.isBranch(_loc2_,mx_internal::_rootModel) && _dataDescriptor.hasChildren(_loc2_,mx_internal::_rootModel))
  587.                {
  588.                   _loc1_ = _dataDescriptor.getChildren(_loc2_,mx_internal::_rootModel);
  589.                }
  590.             }
  591.             clearMenu(_nativeMenu);
  592.             if(mx_internal::_rootModel)
  593.             {
  594.                if(!_loc1_)
  595.                {
  596.                   _loc1_ = mx_internal::_rootModel;
  597.                }
  598.                _loc1_.addEventListener(CollectionEvent.COLLECTION_CHANGE,collectionChangeHandler,false,EventPriority.DEFAULT_HANDLER,true);
  599.                populateMenu(_nativeMenu,_loc1_);
  600.             }
  601.             dispatchEvent(new Event("nativeMenuChange"));
  602.          }
  603.       }
  604.       
  605.       public function unsetContextMenu(param1:InteractiveObject) : void
  606.       {
  607.          param1.contextMenu = null;
  608.       }
  609.       
  610.       public function invalidateProperties() : void
  611.       {
  612.          var _loc1_:Timer = null;
  613.          if(!invalidatePropertiesFlag && nestLevel > 0)
  614.          {
  615.             invalidatePropertiesFlag = true;
  616.             if(UIComponentGlobals.mx_internal::layoutManager)
  617.             {
  618.                UIComponentGlobals.mx_internal::layoutManager.invalidateProperties(this);
  619.             }
  620.             else
  621.             {
  622.                _loc1_ = new Timer(100,1);
  623.                _loc1_.addEventListener(TimerEvent.TIMER,validatePropertiesTimerHandler);
  624.                _loc1_.start();
  625.             }
  626.          }
  627.       }
  628.       
  629.       public function set labelField(param1:String) : void
  630.       {
  631.          if(_labelField != param1)
  632.          {
  633.             _labelField = param1;
  634.             labelFieldChanged = true;
  635.             invalidateProperties();
  636.             dispatchEvent(new Event("labelFieldChanged"));
  637.          }
  638.       }
  639.       
  640.       public function get initialized() : Boolean
  641.       {
  642.          return _initialized;
  643.       }
  644.       
  645.       public function validatePropertiesTimerHandler(param1:TimerEvent) : void
  646.       {
  647.          validateProperties();
  648.       }
  649.       
  650.       public function set labelFunction(param1:Function) : void
  651.       {
  652.          if(_labelFunction != param1)
  653.          {
  654.             _labelFunction = param1;
  655.             labelFieldChanged = true;
  656.             invalidateProperties();
  657.             dispatchEvent(new Event("labelFunctionChanged"));
  658.          }
  659.       }
  660.       
  661.       protected function itemToKeyEquivalentModifiers(param1:Object) : Array
  662.       {
  663.          if(param1 == null)
  664.          {
  665.             return [];
  666.          }
  667.          if(keyEquivalentModifiersFunction != null)
  668.          {
  669.             return keyEquivalentModifiersFunction(param1);
  670.          }
  671.          return [];
  672.       }
  673.       
  674.       protected function itemToKeyEquivalent(param1:Object) : String
  675.       {
  676.          var data:Object = param1;
  677.          if(data == null)
  678.          {
  679.             return "";
  680.          }
  681.          if(keyEquivalentFunction != null)
  682.          {
  683.             return keyEquivalentFunction(data);
  684.          }
  685.          if(data is XML)
  686.          {
  687.             try
  688.             {
  689.                if(data[keyEquivalentField].length() != 0)
  690.                {
  691.                   data = data[keyEquivalentField];
  692.                   return data.toString();
  693.                }
  694.             }
  695.             catch(e:Error)
  696.             {
  697.             }
  698.          }
  699.          else if(data is Object)
  700.          {
  701.             try
  702.             {
  703.                if(data[keyEquivalentField] != null)
  704.                {
  705.                   data = data[keyEquivalentField];
  706.                   return data.toString();
  707.                }
  708.             }
  709.             catch(e:Error)
  710.             {
  711.             }
  712.          }
  713.          return "";
  714.       }
  715.       
  716.       public function validateNow() : void
  717.       {
  718.          if(invalidatePropertiesFlag)
  719.          {
  720.             validateProperties();
  721.          }
  722.       }
  723.       
  724.       private function insertMenuItem(param1:NativeMenu, param2:int, param3:Object) : void
  725.       {
  726.          var _loc7_:String = null;
  727.          var _loc8_:int = 0;
  728.          if(dataProviderChanged)
  729.          {
  730.             commitProperties();
  731.             return;
  732.          }
  733.          var _loc4_:String;
  734.          var _loc5_:* = (_loc4_ = dataDescriptor.getType(param3).toLowerCase()) == "separator";
  735.          var _loc6_:NativeMenuItem = new NativeMenuItem("",_loc5_);
  736.          if(!_loc5_)
  737.          {
  738.             _loc6_.enabled = dataDescriptor.isEnabled(param3);
  739.             _loc6_.checked = _loc4_ == "check" && dataDescriptor.isToggled(param3);
  740.             _loc6_.data = dataDescriptor.getData(param3,mx_internal::_rootModel);
  741.             _loc6_.keyEquivalent = itemToKeyEquivalent(param3);
  742.             _loc6_.keyEquivalentModifiers = itemToKeyEquivalentModifiers(param3);
  743.             _loc7_ = itemToLabel(param3);
  744.             if((_loc8_ = itemToMnemonicIndex(param3)) >= 0)
  745.             {
  746.                _loc6_.label = parseLabelToString(_loc7_);
  747.                _loc6_.mnemonicIndex = _loc8_;
  748.             }
  749.             else
  750.             {
  751.                _loc6_.label = parseLabelToString(_loc7_);
  752.                _loc6_.mnemonicIndex = parseLabelToMnemonicIndex(_loc7_);
  753.             }
  754.             _loc6_.addEventListener(Event.SELECT,itemSelectHandler,false,0,true);
  755.             if(dataDescriptor.isBranch(param3,mx_internal::_rootModel) && dataDescriptor.hasChildren(param3,mx_internal::_rootModel))
  756.             {
  757.                _loc6_.submenu = createMenu();
  758.                populateMenu(_loc6_.submenu,dataDescriptor.getChildren(param3,mx_internal::_rootModel));
  759.             }
  760.          }
  761.          param1.addItem(_loc6_);
  762.       }
  763.       
  764.       public function setContextMenu(param1:InteractiveObject) : void
  765.       {
  766.          var _loc2_:ISystemManager = null;
  767.          param1.contextMenu = nativeMenu;
  768.          if(param1 is Application)
  769.          {
  770.             _loc2_ = Application(param1).systemManager;
  771.             if(_loc2_ is InteractiveObject)
  772.             {
  773.                InteractiveObject(_loc2_).contextMenu = nativeMenu;
  774.             }
  775.          }
  776.       }
  777.       
  778.       protected function itemToMnemonicIndex(param1:Object) : int
  779.       {
  780.          var mnemonicIndex:int = 0;
  781.          var data:Object = param1;
  782.          if(data == null)
  783.          {
  784.             return -1;
  785.          }
  786.          if(mnemonicIndexFunction != null)
  787.          {
  788.             return mnemonicIndexFunction(data);
  789.          }
  790.          if(data is XML)
  791.          {
  792.             try
  793.             {
  794.                if(data[mnemonicIndexField].length() != 0)
  795.                {
  796.                   mnemonicIndex = data[mnemonicIndexField];
  797.                   return mnemonicIndex;
  798.                }
  799.             }
  800.             catch(e:Error)
  801.             {
  802.             }
  803.          }
  804.          else if(data is Object)
  805.          {
  806.             try
  807.             {
  808.                if(data[mnemonicIndexField] != null)
  809.                {
  810.                   mnemonicIndex = data[mnemonicIndexField];
  811.                   return mnemonicIndex;
  812.                }
  813.             }
  814.             catch(e:Error)
  815.             {
  816.             }
  817.          }
  818.          return -1;
  819.       }
  820.       
  821.       public function validateProperties() : void
  822.       {
  823.          if(invalidatePropertiesFlag)
  824.          {
  825.             commitProperties();
  826.             invalidatePropertiesFlag = false;
  827.          }
  828.       }
  829.       
  830.       [Bindable("labelFunctionChanged")]
  831.       public function get labelFunction() : Function
  832.       {
  833.          return _labelFunction;
  834.       }
  835.       
  836.       public function set showRoot(param1:Boolean) : void
  837.       {
  838.          if(_showRoot != param1)
  839.          {
  840.             showRootChanged = true;
  841.             _showRoot = param1;
  842.             invalidateProperties();
  843.          }
  844.       }
  845.    }
  846. }
  847.